/* $$Id: RssReaderMIDlet.java 24 2008-01-08 16:19:22Z qxodream $$
 *
 * RssReaderMidlet --  RSS reader for J2ME(midp)
 * The original codes of this porgram is from
 * RssOwlMIDlet(zhengyun@gmail.com)
 *
 * Copyright (c) 2007-2008 QXO(qxodream@gmail.com)
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by the Free
 * Software Foundation; either version 2 of the License, or (at your option)
 * any later version.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
 * more details.
 *
 * You should have received a copy of the GNU General Public License along
 * with this program; if not, write to the Free Software Foundation, Inc.,
 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 */

package com.ultrapower.midlet;

import javax.microedition.lcdui.Alert;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Displayable;
import javax.microedition.midlet.MIDlet;
import javax.microedition.midlet.MIDletStateChangeException;

import com.ultrapower.control.GUIController;

/**
 * 类说明：实际上应该算作MVC中的View部分，是MIDlet的主界面。<br/> RssReaderMIDlet is an application
 * that can read RSS feeds. User can store multiple RSS feeds as bookmarks into
 * application's record store.
 *
 * @author Tommi Laukkanen
 * @author zhengyun@ultrapower 2005.10.07
 * @author QXO(qxodream@gmail.com)
 *
 */
public class RssReaderMIDlet extends MIDlet {
	private Display display;
	private static GUIController controller;

	/**
	 * default constructor
	 */
	public RssReaderMIDlet() {
		super();
		display = Display.getDisplay(this);
	}

	/*
	 * (non-Javadoc)
	 *
	 * @see javax.microedition.midlet.MIDlet#startApp()
	 */
	protected void startApp() throws MIDletStateChangeException {
		controller = new GUIController(this);
		controller.init();// 初始化RecordStore
	}

	/*
	 * (non-Javadoc)
	 *
	 * @see javax.microedition.midlet.MIDlet#pauseApp()
	 */
	protected void pauseApp() {
		this.notifyPaused();
	}

	/*
	 * (non-Javadoc)
	 *
	 * @see javax.microedition.midlet.MIDlet#destroyApp(boolean)
	 */
	protected void destroyApp(boolean arg0) throws MIDletStateChangeException {
		controller = null;
	}

	/***************************************************************************
	 * // RssReaderMIDlet::setCurrent() // // Description: // 设置当前显示的界面 // //
	 * Parameters: // Return Values: // Author: // zhengyun@ultrapower
	 * 2005.10.07 //
	 **************************************************************************/
	public void setCurrent(Displayable disp) {
		display.setCurrent(disp);
	}

	public void setCurrent(Alert alert, Displayable disp) {
		display.setCurrent(alert, disp);
	}

	public Displayable getCurrent() {
		return display.getCurrent();
	}

	/***************************************************************************
	 * // RssReaderMIDlet::getCurrentDisplay() // // Description: //
	 * 获取当前的Display，这样可以让其他类能够控制要显示什么 // // Parameters: // Return Values: //
	 * Author: // zhengyun@ultrapower 2005.10.07 //
	 **************************************************************************/
	public Display getCurrentDisplay() {
		return display;
	}

	public void exit(boolean arg0) {
		try {
			destroyApp(arg0);
			notifyDestroyed();
		} catch (MIDletStateChangeException e) {
			//
		}
	}
}
